from core.support import set_cutscene
from core.basehandler import BaseHandler
from core.room import Room
from items.pointer import Pointer
from items.bottlecap import BottleCap
from items.flipflop import FlipFlop
from core.action import Action

class TeamRoom(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        self.imagechange = False
        # add inventory items
        self.add_item(Pointer())
        self.add_item(BottleCap())
        self.add_item(FlipFlop())
            
        # build list of actions
        self.add_action(Exit)
        self.add_action(LookAround)
        
    # return description of room.
    def get_description(self):
        return "Clayton Porter wakes up hazy and confused in empty team room at SMG. His pockets are completely empty, and someone has stolen his MBA."
    
    # return image of room
    def get_image(self):
        if self.imagechange:
            return 'claytonporter.jpg'
        else:
            return 'claytonstart.jpg'


class TeamRoomHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return TeamRoom

# define actions for this room

class Exit(Action):
    def __init__(self):
        Action.__init__(self, "Exit")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Leave Team Room"
    
    def get_image(self):
        return "buttons.gif"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'hallway' #to change to "Hallway' when class is ready
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

    def do_action(self,game,room,request):
        self.room.imagechange = False
        return

class LookAround(Action):
    def __init__(self):
        Action.__init__(self, "LookAround")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Look around Team Room."
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'team_room'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    def do_action(self,game,room,request):
        if room.get_id() == 'team_room':        
            set_cutscene("Writing on the blackboard reads: It all ends at the wall of corn.")
            self.room.imagechange = True
        else:
            set_cutscene("There's nothing to see here")
        return
    
    def is_enabled(self):
        if self.room.imagechange == True:
            return False
        else:
            return True